BOD Constraints tab

An object constraint is a business rule that is applied to the entire object instead of to individual properties within the object.

By default, the BOD Constraints tab is found in the following location:

■    Tools > Business object designer, then from the toolbar choose New > Design Business Definition (or select an existing object, then from the toolbar choose Edit), then select the Constraints.

Constraints

Lists the constraints that already exist for this object or says “New” if none already exist. With New selected, the object’s designer is able to Add a new constraint for the object. If an existing constraint is selected, its details are shown below and may be edited, or it can be deleted by clicking Remove to the right of the list.

Name

The name of the constraint being created or edited.

Caution! Do not use SQL Server reserved keywords as constraint names.

Active

Indicates whether the constraint should be run or is temporarily disabled. If checked, the constraint runs. If unchecked, it does not run but the code and other settings on this screen remain a part of the object’s design.

Triggering Event

Indicates when the constraint should run. More than one selection may be made. Choices are:

■    Add/New – When the object is saved for the first time.

■    Update – When the object is being saved after already having been saved a first time.

■    Delete – When the object is being deleted.

Severity

Indicates what happens if the constraint fails. Possible choices are:

■    Warning – The end user is shown a warning message but the object is allowed to save/be updated/deleted.

■    Error – The end user is shown a user error message and the object cannot be saved/updated/deleted until the error is resolved.

■    System Error – The end user is shown a system error message and the object cannot be saved/updated/deleted until the error is resolved.

Message

The warning or error message to display if the constraint fails. If no message is entered, a default warning or error message appears.

Description

Allows the object’s designer to enter a text description of the purpose of the constraint. This is for documentation purposes only.

Code

Allows the object’s designer to enter the C# code that determines if the object passes the constraint (that is, if all values are valid). The code should be written to set the value of the constraintPassed variable appropriately: to True if the constraint passed or False if it did not, or the reverse if Acceptance is unchecked.